home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Missions Cog Script
- #
- # POW_RAILCHARGES_M.COG
- #
- # POWERUP Script - Rail Charges
- #
- # [YB & CYW] + [RF]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
-
- symbols
-
- thing powerup local
- thing player local
- thing sender local
- flex damage local
- int bin=15 local
- sound pickupsnd=helthpu1.wav local
- sound respawnsnd=Activate01.wav local
- flex amount local
-
- template sparkTemplate=+sparks local
- int scratch local
-
- sound fireSound=RailChargeFire01.WAV local
- template projectile=+sraildet local
- template blast=+small_exp local
-
- vector thingPos local
- vector randVec local
-
- int bin_contents=0 local
-
- message timer
- message created
- message damaged
- message touched
- message taken
- message respawn
-
- end
-
- # ========================================================================================
-
- code
-
- created:
- SetThingUserData(GetSenderRef(), 30); // set the initial user data (i.e. "health")
- Return;
-
- # ............................................................................................
-
- touched:
- player = GetSourceRef();
-
- if (GetInv(player, bin) < GetInvMax(player, bin))
- {
- TakeItem(GetSenderRef(), -1);
- call taken;
- }
-
- Return;
-
- # ........................................................................................
-
- damaged:
- damage = GetParam (0);
- sender = GetSenderRef();
-
- // If it's already dead, don't allow any more damage.
- if ((GetThingUserData (sender) == 0.0) || (rand() < 0.5))
- return;
-
- // see if this will cause the explosion
- if (GetThingUserData (sender) <= damage)
- {
- SetThingUserData(sender, 0.0);
-
- CreateThingNR(sparkTemplate, sparkSpot);
-
- SetTimerEx(0.5, 2, sender, 0);
- }
- else
- {
- SetThingUserData(sender, GetThingUserData (sender) - damage);
- }
-
- ReturnEx (0);
- return;
-
- # ........................................................................................
-
- taken:
- player = GetSourceRef();
- powerup = GetSenderRef();
-
- // If the object has been destroyed, don't award it to the player.
- // if (GetThingUserData (sender) == 0.0)
- // return;
-
- // Print("Rail Charges");
- jkPrintUNIString(player, bin);
-
- // Do effects.
- PlaySoundLocal(pickupsnd, 1, 0, 0);
- AddDynamicTint(player, 0.0, 0.0, 0.2);
-
- // store the old bin contents
- bin_contents = GetInv(player, bin);
-
- // Increment powerup amount.
- ChangeInv(player, bin, 3.0);
-
- // Check for Auto Reload
- if(GetAutoReload() & 1)
- {
- if(!bin_contents)
- {
- if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
- {
- // Try to autoselect and see if the best weapon is the railgun
- if(AutoSelectWeapon(player, 2) == 7) SelectWeapon(player, 7);
- }
- }
- }
-
- Return;
-
- # ........................................................................................
-
- respawn:
- SetThingUserData(GetSenderRef(), 30); // set the initial user data (i.e. "health")
- PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
-
- Return;
-
- # ........................................................................................
-
- timer:
- sender = GetParam(0);
-
- if (GetSenderID() == 1)
- {
- thingPos = GetThingPos(sender);
-
- scratch = GetParam(1);
-
- while (scratch > 0)
- {
- randVec = VectorSet(rand() * 20, rand() * 360, 0);
- CreateThingAtPosNR(projectile, GetThingSector(sender), thingPos, randVec);
-
- scratch = scratch - 1;
- }
-
- TakeItem(sender, -1);
- }
- else
- if (GetSenderID() == 2)
- {
- SetTimerEx(0.5, 1, sender, 2);
-
- CreateThingNR(blast, sender);
- }
- return;
- end
-
-